<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>register</title>
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<link rel="shortcut icon" href="favicon.ico">
<link rel="icon" href="favicon.ico">

<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<!--必要样式-->
<link rel="stylesheet" type="text/css" href="css/component.css" />



</head>
<body>
	<div class="container demo-1">
		<div class="content">
			<div id="large-header" class="large-header">
				<canvas id="demo-canvas"></canvas>
				<div class="logo_box">
					<h3>欢迎你</h3>
					<form id="registerFrom" action="/time/user_register.action"
						name="f" method="post">

						<span id="hintSpan"
							style="position: absolute; left: 40px; top: 90px; color: orangered;">
						</span>

						<div class="input_outer">
							<span class="u_user"></span> <input class="text"
								name="username"
								onblur="checkUsername($(this).val())"
								style="color: #FFFFFF !important" type="text"
								placeholder="请输入账户">
						</div>
						<div class="input_outer">
							<span class="us_uer"></span> <input name="password"
								onblur="checkPassword($(this).val())" class="text"
								style="color: #FFFFFF !important; position: absolute; z-index: 100;"
								value="" type="password" placeholder="请输入密码">
						</div>

						<div class="mb2">
							<a class="act-but submit" href="javascript: register();"
								style="color: #FFFFFF; width: 330px;">注册</a>
						</div>

					</form>
				</div>
			</div>
		</div>
	</div>
	<!-- /container -->
	<script src="js/TweenLite.min.js"></script>
	<script src="js/EasePack.min.js"></script>
	<script src="js/rAF.js"></script>
	<script src="js/demo-1.js"></script>
	<script src="../parent-time/js/jquery-2.1.0.min.js"></script>
	
	<script>

	$(function(){
		var time = new Date();
		var HH = time.getHours();
		if (HH > 18) {
			$('.demo-1,.large-header').css('background-image','url(private_img/loginBg_1.jpg)');
		} 
		
	});

	var flag = true;
	function checkUsername(username) {
		if (username == "") {
			$("#hintSpan").html("用户名及密码不能为空");
			flag = false;
			return ;
		}
		
		if(/[\u4E00-\u9FA5]/g.test(username)){
			$("#hintSpan").html("用户名由大小写字母数字及下划线组成");
			flag = false;
			return ;
		}

		// 因为post和js执行不在一个线程,导致return的flag是undefined
		// 为了解决这个问题在jquery中自定义了ajaxSetup的async: false
		$.post("/time/user_preventRepetitionByUsername.action", {"username" : username}, function(data) {

			if (data.checkResult == '用户名已存在') {
				$("#hintSpan").html("用户名以存在");
				flag = false;
			} 
		});
	};

	function checkPassword(password) {
		if (password == "") {
			$("#hintSpan").html("用户名及密码不能为空");
			flag = false;
		}

	}

	function register() {
		$('input[type=text]').blur();
		$('input[type=password]').blur();
		
		if (flag) {
			$("#registerFrom").submit();
		}
		flag = true;
	};
</script>
	
</body>
</html>